<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
	<%@include file="admindex.jsp"%>
	<div style="width: 70%;margin-left: 70%;">
	<input type="button" onclick="delAll()" value="批量删除" />
	<input type="button" onclick="che()" value="全选/反选" />
	</div>
	<table class="table table-dark" style="margin-left: 15%;margin-right: 15%;width: 70%;">
	<thead>
		<tr>
			<th><input type="checkbox" onclick="cheAll()" id="che"></th>
			<th scope="col">学号</th>
			<th scope="col">姓名</th>
			<th scope="col">性别</th>
			<th scope="col">专业</th>
		</tr>
		</thead>
		<tbody>
    <c:forEach var="s" items="${sPage.list }">
    <tr>
      <th scope="row"><input type="checkbox" onclick="cheAll()" value="${s.id }" id="che"></th>
      <td>${s.sno }</td>
      <td>${s.sname }</td>
      <td>${s.ssex }</td>
      <td>${s.specialities }</td>
    </tr>
      </c:forEach>
  </tbody>
	</table>
	<script>
		//全选
		function cheAll() {
			var cek = $("#che")[0].checked;
			var ck = $("input[name='ck']");
			for (var i = 0; i < ck.length; i++) {
				ck[i].checked = cek;
			}
		}
		//反选
		function che() {
			var cks = document.getElementsByName("ck");
			for (var i = 0; i < cks.length; i++) {
				cks[i].checked = !cks[i].checked;
			}
		}
		//批量删除
		function delAll() {
			var ck = $("input:checked[name='ck']");
			if (ck.length == 0) {
				alert("请选择,然后进行删除");
				return;
			}
			var f = confirm("确认删除!!");
			if (!f) {
				return;
			}
			for (var i = 0; i < ck.length; i++) {
				ck[i].parentNode.parentNode.remove();
			}
		}
	</script>
</body>
</html>




